#pragma once

#include <stack>
#include <string>

#include <HitoriBoard.h>

#include "Common.h"
#include <AcceptDialog.hpp>
#include <Array.hpp>
#include <AtlasTexture.hpp>
#include <Button.hpp>
#include <Control.hpp>
#include <GridContainer.hpp>
#include <Label.hpp>
#include <PackedScene.hpp>
#include <ResourceLoader.hpp>
#include <SceneTree.hpp>
#include <SceneTreeTimer.hpp>
#include <String.hpp>
#include <TextureButton.hpp>
#include <Vector2.hpp>

namespace godot {
class Playground: public Control {
	GODOT_CLASS(Playground, Control);
	
public:
	Playground();

	static void _register_methods();
	
	void _init();
	void _ready();
	
	void setup(const unsigned short rows, const unsigned short cols);
	
	void _process(float delta);
	void _timeout();
	void _update_history(const unsigned short index);
	
	void _on_AcceptDialog_confirmed();
	void _on_CheckButton_pressed();
	void _on_PauseButton_pressed();
	void _on_UndoButton_pressed();
	void _on_RedoButton_pressed();
	void _on_ReturnButton_pressed();

private:
	bool hudIsRevealed = true;
	int64_t time = 0;
	std::unique_ptr<HitoriGenerator::HitoriBoard> game;
	std::unique_ptr<std::deque<unsigned short>> undoStack;
	std::unique_ptr<std::stack<unsigned short>> redoStack;
	std::unique_ptr<std::vector<Node*>> cells;
	
	bool __is_solved() const;
	void __undo();
	void __redo();
};
}